import Cookies from "js-cookie"
import state from "./state"

const  getters = {
    loginToken(state){
        if(state.token == null || state.token.length == 0){
            state.token = Cookies.get('token')
            if(!state.token){
                state.token = localStorage.getItem('token')
            }
        }

        return state.token
    },

    // 用户详情
    loginUserInfo(){
        if(!state.userInfo || !state.userInfo.id){
            state.userInfo = JSON.parse(localStorage.getItem('userInfo'))
        }

        return state.userInfo
    }
}

export default getters